﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using IDAL;

namespace DAL
{
    public class UserDAL<T> : IUserDAL<T> where T : class
    {
        public UserDAL(HotelDbContext db)
        {
            Db = db;
        }

        public HotelDbContext Db { get; }
        //添加
        public async Task<int> AddAsync(T t)
        {
            Db.Set<T>().Add(t);
            return await Db.SaveChangesAsync();
        }

        public Task<int> AddAsyncd(List<T> t)
        {
            throw new NotImplementedException();
        }

        public Task<int> DeleteAllAsync(List<T> t)
        {
            throw new NotImplementedException();
        }

        public Task<int> DeleteAsync(T t)
        {
            throw new NotImplementedException();
        }
        //显示
        public IQueryable<T> GetAllAsync()
        {
            return Db.Set<T>().AsQueryable();
        }
        //修改
        public async Task<int> UpdateAsync(T t)
        {
            Db.Set<T> ().Update(t);
            return await Db.SaveChangesAsync();
        }

        public Task<int> UpdateAsyncd(List<T> t)
        {
            throw new NotImplementedException();
        }
    }
}
